home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 342_01.zip / DIODESC.TXT < prev    next >
Text File  |  1993-04-03  |  7KB  |  190 lines

  1. *   ----------------------------------------------------------------------
  2. *   File        :   DIODESC.TXT
  3. *   Creator     :   Blake Miller
  4. *   Version     :   01.01.00    February 1991
  5. *   Purpose     :   Describe functions in DIOLIB?.LIB
  6. *   Revision    :   February 28, 1991
  7. *   -----------------------------------------------------------------------
  8.  
  9.     Collection of routines for digital I/O using a
  10.     Computer Boards Inc. CIOAD-16 or a Metrabyte PIO12 compatible
  11.     digital I/O board containing at least 1 Intel 8255 Programmable
  12.     Peripheral Interface integrated circuit.
  13.     The functions can assume a small, medium, or large memory model.
  14.     Link your program with the correct DIOLIB?.LIB library memory model:
  15.         DIOLIBL.LIB -> Large  Memory Model
  16.         DIOLIBM.LIB -> Medium Memory Model
  17.         DIOLIBS.LIB -> Small  Memory Model
  18.  
  19.     Note that some of the functions use inline assembly language as is
  20.     compatible with Microsoft Quick C Version 2.0 and later.  This inline
  21.     assembly is also compatible with Microsoft C Version 6.0, or so I have
  22.     been told.  The INPort and OUTPort type instructions will have to be
  23.     modified or changed to a different function call for use with the
  24.     Borland Turbo C C compiler or probably with any other type of compiler.
  25.  
  26.     I would like to make an aesthetic comment.
  27.     These routines were written for C programmers.  Therefore, all offset
  28.     for bits, array elements, data array elements, etc. assume a ZERO (0)
  29.     offset!  Many of the commercial libraries available use a base of 1.
  30.     That seems fine for appeasing Pascal and BASIC programmers, but when I
  31.     was modifying my libraries I noticed a lot of code compensating for an
  32.     offset of 1.  I was adding one to the port or subtracting 1 here and
  33.     there.  It soon seemed rather pointless.  Therefore, I screamed
  34.     "NO MORE!" and decided to use offsets of zero!
  35.  
  36.     Look at the source code for each function for an exact description of
  37.     what each one does.  I wrote the program DIOTST01.C to demonstrate the
  38.     use of the functions.  Last tiem I chekced, it worked great on a
  39.     Metrabyte PIO-12 Digital I/O Board.  The functions also correctly
  40.     controlled the 8255 digital I/O port on a Computer Boards, Inc. CIO-AD16
  41.     data acquisition board.
  42.  
  43.  
  44. FUNCTION SYSNOPSES:
  45. -------------------
  46.  
  47. /*- DIO : Initialize Data Space --------------**    DIOFNC01.C
  48.  *  Initialize the data to safe values.
  49.  *  DOES NOT do any hardware data modification.  That is,
  50.  *  no input or output to the boards occurs.
  51.  *  Passed:
  52.  *      pointer :   DIODAT
  53.  *      short   :   base address
  54.  *  Returns:
  55.  *      nothing
  56.  */
  57. void dio_init (DIODAT *data, short address)
  58.  
  59.  
  60. /*- DIO : Configure --------------------------**    DIOFNC02.C
  61.  *  Configure the 8255 for all ports in Mode 0.
  62.  *  Pass an integer representing the IN or OUT state for each port.
  63.  *  TRUE (!0) will mean input, and FALSE (0) will mean output.
  64.  *  Passed:
  65.  *      pointer :   DIODAT
  66.  *      short   :   direction Port A
  67.  *      short   :   direction Port B
  68.  *      integer :   direction Port C Low
  69.  *      integer :   direction Port C High
  70.  *  Returns:
  71.  *      nothing
  72.  */
  73. void dio_config (DIODAT *data, int pa_dir, int pb_dir,
  74.                                int cl_dir, int ch_dir)
  75.  
  76.  
  77. /*- DIO : Bit Put ----------------------------**    DIOFNC03.C
  78.  *  Set/Clear one of the bits in the 8255.
  79.  *  A state of 1 sets the bit and a state of 0 clears the bit.
  80.  *  The bit number should be from 0 - 23 as follows:
  81.  *   0 = Port A Bit 0;   7 = Port A Bit 7
  82.  *   8 = Port B Bit 0;  15 = Port B Bit 7
  83.  *  16 = Port C Bit 0;  23 = Port C Bit 7
  84.  *  Passed:
  85.  *      pointer :   DIODAT
  86.  *      integer :   bit number
  87.  *      integer :   state : TRUE (!0) = SET, FALSE (0) = CLEAR
  88.  *  Returns:
  89.  *      nothing
  90.  *      Loads stat with appropriate error code
  91.  */
  92. void dio_bitput (DIODAT *data, int bit, int state)
  93.  
  94.  
  95. /*- DIO : Bit Get ----------------------------**    DIOFNC04.C
  96.  *  Read one of the bits in the 8255.
  97.  *  A state of 1 indicates a set bit and a state of 0
  98.  *  indicates a clear bit.
  99.  *  The bit number should be from 0 - 23 as follows:
  100.  *   0 = Port A Bit 0;   7 = Port A Bit 7
  101.  *   8 = Port B Bit 0;  15 = Port B Bit 7
  102.  *  16 = Port C Bit 0;  23 = Port C Bit 7
  103.  *  Passed:
  104.  *      pointer :   DIODAT
  105.  *      integer :   bit number
  106.  *      pointer :   integer :   state : 1 = SET, 0 = CLEAR
  107.  *  Returns:
  108.  *      nothing
  109.  *      Loads stat with approrpiate error code.
  110.  *      Loads state with 0 or 1.
  111.  */
  112. void dio_bitget (DIODAT *data, int bit, int *state)
  113.  
  114.  
  115. /*- DIO : Byte Put ---------------------------**    DIOFNC05.C
  116.  *  Write one of the bytes in the 8255.
  117.  *  The port number should be 0 - 2 as follows:
  118.  *  Use the defines (DIOLIB.H):
  119.  *  DIO_PORTA = 0 = Port A
  120.  *  DIO_PORTB = 1 = Port B
  121.  *  DIO_PORTC = 2 = Port C
  122.  *  Passed:
  123.  *      pointer         :   DIODAT
  124.  *      integer         :   port number
  125.  *      unsigned char   :   port data
  126.  *  Returns:
  127.  *      nothing
  128.  *      Loads stat with any error ID.
  129.  */
  130. void dio_put_byte (DIODAT *data, int p_num, unsigned char p_dat)
  131.  
  132.  
  133. /*- DIO : Byte Get ---------------------------**    DIOFNC06.C
  134.  *  Read one of the bytes in the 8255.
  135.  *  The port number should be 0 - 2 as follows:
  136.  *  Use the defines (DIOLIB.H):
  137.  *  DIO_PORTA = 0 = Port A
  138.  *  DIO_PORTB = 1 = Port B
  139.  *  DIO_PORTC = 2 = Port C
  140.  *  Reads the 8255 and returns data in variable as well as
  141.  *  loading port data area.
  142.  *  Passed:
  143.  *      pointer :   DIODAT
  144.  *      integer :   port number
  145.  *      pointer :   unsigned char : returned port data
  146.  *  Returns:
  147.  *      nothing
  148.  *      Loads stat with appropriate error code.
  149.  *      Loads p_dat with returned data.
  150.  */
  151. void dio_get_byte (DIODAT *data, int p_num, unsigned char *p_dat)
  152.  
  153.  
  154. /*- DIO : Dump Bytes -------------------------**    DIOFNC07.C
  155.  *  Write all of the bytes from the data area to the 8255.
  156.  *  Passed:
  157.  *      pointer :   DIODAT
  158.  *  Returns:
  159.  *      nothing
  160.  */
  161. void dio_dump_bytes (DIODAT *data)
  162.  
  163.  
  164. /*- DIO : Load Bytes -------------------------**    DIOFNC08.C
  165.  *  Read all of the bytes of the 8255 into the data area.
  166.  *  Passed:
  167.  *      pointer :   DIODAT
  168.  *  Returns:
  169.  *      nothing
  170.  */
  171. void dio_load_bytes (DIODAT *data)
  172.  
  173.  
  174. /*- DIO : Byte Put ---------------------------**    DIOFNC09.C
  175.  *  Write a byte to one of the 80X86 ports.
  176.  *  Duplicates the library function outp()
  177.  */
  178. void dio_bput (int d_port, unsigned char d_byte)
  179.  
  180.  
  181. /*- DIO : Byte Get ---------------------------**    DIOFNC10.C
  182.  *  Read a byte from one of the 80X86 ports.
  183.  *  Duplicates the library function inp()
  184.  */
  185. void dio_bget (int d_port, unsigned char *d_byte)
  186.  
  187. *   ----------------------------------------------------------------------
  188. *   END DIODESC.TXT Text Description File
  189. *   ----------------------------------------------------------------------
  190.